package com.alibaba.excel.write.metadata.fill;

import com.alibaba.excel.enums.WriteDirectionEnum;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 填写配置
 **/
@Getter
@Setter
@EqualsAndHashCode
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FillConfig {

    //  写方向枚举：竖写、横写
    private WriteDirectionEnum direction;

    /**
     * 是否强制新行
     * 每次使用列表参数时创建一个新行。如果需要，默认创建。
     * Create a new row each time you use the list parameter.The default create if necessary.
     * <p>
     * 警告：如果使用 <code>forceNewRow<code> 设置为 true，将无法使用异步写入文件，简单地说整个文件将存储在内存中。
     * Warnning:If you use <code>forceNewRow</code> set true, will not be able to use asynchronous write file, simply say the whole file will be stored in memory.
     */
    private Boolean forceNewRow;

    /**
     * 自动继承样式
     * Automatically inherit style
     *
     * default true.
     */
    private Boolean autoStyle;

    private boolean hasInit;

    public void init() {
        if (hasInit) {
            return;
        }
        if (direction == null) {
            direction = WriteDirectionEnum.VERTICAL;
        }
        if (forceNewRow == null) {
            forceNewRow = Boolean.FALSE;
        }
        if (autoStyle == null) {
            autoStyle = Boolean.TRUE;
        }
        hasInit = true;
    }
}
